package edu.gmu.middleware;

import java.nio.ByteBuffer;

/**
 * The SinkDataEvent object represents change to source object.
 */
public class SinkDataEvent extends java.util.EventObject
{   
    /**
     * The Data events Time stamp.  The time stamp is in
     * UTC format that indicates when the input event was
     * created.
     *
     * @see #getWhen()
     */
    private long when;
    
    /**
     * header
     */
    private Header header = null;
    
    /**
     * in
     */
    private ByteBuffer in = null;
    
    /**
     * sink source of in
     */
    private Sink sink = null;

    /**
     * Constructs a SinkDataEvent object with the specified parameters.
     * @param source
     * @param when
     * @param header
     * @param in
     */
    public SinkDataEvent(   Object source,
                            long when,
                            Header header,
                            ByteBuffer in,
                            Sink sink)
    {
        super(source);
        this.when   = when;
        this.header = header;
        this.in     = in;
        this.sink   = sink;
    }


    /**
     * Returns the timestamp of when this event occurred.
     * @return long
     */
    public long getWhen()
    {
        return this.when;
    }
    
    /**
     * Gets header.
     * @return header
     */
    public Header getHeader( )
    {
        return this.header;
    }
    
    /**
     * Gets in.
     * @return in
     */
    public ByteBuffer getIn( )
    {
        return this.in;
    }
    
    /**
     * Gets sink.
     * @return sink
     */
    public Sink getSink( )
    {
        return this.sink;
    }

    /**
     * Returns a String object representing this Event's values.
     * @return  String object representing this object.
     */
    public String toString()
    {
        return new String(super.toString() +
                          "\n     when: " + this.getWhen() +
                          "\n   header: " + header
                          );
    }

}
